{extend name="public:layout" /}
{block name="title"}编辑碎片{/block}
{block name="head"}{/block}
{block name="body"}
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="ibox">
        <div class="ibox-title">
            <ol class="breadcrumb">
                <li>
                    <i class="fa fa-hand-o-right"></i>
                    <a href="{:url('index')}">碎片管理</a>
                </li>
                <li class="active">修改碎片</li>
            </ol>
        </div>
        <div class="ibox-content">
            <form method="post" class="form-horizontal" id="form">
                <input type="hidden" name="patch_id" value="{$info.patch_id}" />
                <input type="hidden" name="patch_type" value="{$info.patch_type}" />
                <div class="form-group">
                    <label class="col-sm-2 control-label">碎片名称</label>
                    <div class="col-sm-4">
                        <input type="text" class="form-control" placeholder="请输入碎片名称"
                               name="patch_title" value="{$info.patch_title}" datatype="*" />
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">碎片标识</label>
                    <div class="col-sm-4">
                        <input type="text" class="form-control" placeholder="请输入碎片标识"
                               name="patch_sn" value="{$info.patch_sn}" datatype="*" />
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">碎片类型</label>
                    <div class="col-sm-4">
                        <p class="form-control-static">{$info.patch_type_text}</p>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">碎片说明</label>

                    <div class="col-sm-6">
                        <textarea class="form-control" name="patch_desc" rows="3">{$info.patch_desc}</textarea>
                    </div>
                </div>
                {eq name="info.patch_type" value="102001"}
                <div id="content-102001">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">图片地址</label>

                        <div class="col-sm-6">
                            <p class="form-control-static">
                                {:widget('common/Form/singleImg',['field'=>'img','value'=>$info['content_format']['img'],$uid])}
                            </p>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">链接地址</label>

                        <div class="col-sm-6">
                            <input type="text" class="form-control" placeholder="请输入链接地址"
                                   name="url" value="{$info.content_format.url}"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">图片说明</label>

                        <div class="col-sm-6">
                            <textarea class="form-control" name="desc" rows="3">{$info.content_format.desc}</textarea>
                        </div>
                    </div>
                </div>
                {/eq}
                {eq name="info.patch_type" value="102002"}
                <div id="content-102002">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">选择图片</label>

                        <div class="col-sm-10">
                            {:widget('common/Form/moreTextImg',['field'=>'items','value'=>$info['patch_content'],'',$uid])}
                        </div>
                    </div>
                </div>
                {/eq}
                {eq name="info.patch_type" value="102003"}
                <div id="content-102003" class="content-box">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">碎片代码</label>

                        <div class="col-sm-8">
                            <textarea class="form-control" name="code_content" rows="8">{$info.patch_content}</textarea>
                        </div>
                    </div>
                </div>
                {/eq}
                {eq name="info.patch_type" value="102004"}
                <div id="content-102004" class="content-box">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">内容</label>

                        <div class="col-sm-8">
                            {:widget('common/Form/ueditor',['html_content',$info['content_format'],$uid])}
                        </div>
                    </div>
                </div>
                {/eq}
                <div class="form-group">
                    <label class="col-sm-2 control-label">状态</label>

                    <div class="col-sm-10">
                        <label class="radio-inline i-checks">
                            <input type="radio" checked name="patch_status" value="0"> 禁用
                        </label>
                        <label class="radio-inline i-checks">
                            <input type="radio" name="patch_status" value="1" checked> 启用
                        </label>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-10 col-sm-offset-2">
                        <button class="btn btn-primary" type="button" id="btnSub">
                            保存内容
                        </button>
                        <a href="{:url('index')}" class="btn btn-white">取消</a>
                        <span id="validError"></span>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
{/block}
{block name="script"}
<script type="text/javascript">
    $(function () {
        iCheck();
        $("#patchType").change(function () {
            var patchType = $(this).val();
            var obj = $('#content-'+patchType);
            $('.content-box').hide();
            $(obj).show();
        });
        $("#patchType").trigger("change"); //加载触发
        ajaxSubForm('#btnSub');
    })
</script>
{/block}